package com.quick.controller;

import com.quick.base.Page;
import com.quick.base.Search;
import com.quick.service.ISysPostService;
import com.quick.sys.domain.dto.SysPostDTO;
import com.quick.sys.domain.search.SysPostSearch;
import com.quick.sys.domain.vo.SysPostVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;

import java.util.List;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("api/sys/post")
@Api(tags = "岗位菜单")
@AllArgsConstructor
public class SysPostController {
	private final ISysPostService sysPostService;

	@ApiOperation(value = "岗位分页查询列表", notes = "岗位分页查询列表")
	@PostMapping("search")
	public Page<SysPostVo> search(@RequestBody Search<SysPostSearch> search) {
		return sysPostService.search(search);
	}

	@ApiOperation(value = "新增岗位", notes = "新增岗位")
	@PostMapping("add")
	public Boolean addPost(@RequestBody SysPostDTO role) {
		return sysPostService.saveSysPost(role);
	}

	@ApiOperation(value = "查询岗位", notes = "查询岗位")
	@GetMapping("query/{id}")
	public SysPostVo query(@PathVariable("id") Long id) {
		return sysPostService.queryById(id);
	}

	@ApiOperation(value = "删除岗位", notes = "删除岗位")
	@GetMapping("del/{id}")
	public Boolean del(@PathVariable("id") Long id) {
		return sysPostService.delById(id);
	}

	@ApiOperation(value = "批量删除岗位", notes = "批量删除岗位")
	@PostMapping("batchDel")
	public Boolean batchDel(@PathVariable("id") List<Long> ids) {
		return sysPostService.batchDel(ids);
	}
}
